<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>常见的网页布局</title>
    <style>

        *{
            margin:0;
            padding: 0;
        }

        li{
            list-style: none;
        }

          /* 只要是通栏的盒子(和浏览器一样宽) 不需要指定宽度(默认和父盒子一样宽,这里的父盒子是body) */
        .top{
            background-color: gray;
            height: 50px;
            margin-bottom: 10px;
        }
        
        .banner{
            background-color: #ccc;
            width: 980px;
            height: 100px;
            margin: 0 auto;
        }

        .body{
            width: 980px;
            margin: 0 auto;
            background-color: pink;
            margin-top: 10px;
        }

        .box1 li{
            background: gray;
            width: 237px;
            height: 100px;
            float: left;
            margin-right: 10px;
        }

        .box1 .last,.box2 .last{
            margin-right: 0;
        }

        .clearfix {
            clear: both;
        }

        .box2{
           margin-top: 10px;
        }

        .box2 li{
            width: 237px;
            height: 300px;
            background-color: gray;
            float: left;
            margin-right: 10px;
        }

          /* 只要是通栏的盒子(和浏览器一样宽) 不需要指定宽度 */
        .footer {
            margin-top: 10px;
            background-color: gray;
            height: 265px;
        }

    </style>
</head>
<body>
    <div class="top">top</div>
    <div class="banner">banner</div>
    <div class="body">
            <ul class="box1">
                <li>1</li>
                <li>2</li>
                <li>3</li>
                <li class="last">4</li>
            </ul>
        <!-- 清除浮动,因为.box1父盒子未指定高度 -->
        <div class="clearfix"></div>
        <ul class="box2">
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li  class="last" >4</li>
        </ul>
        <!-- 清除浮动,因为.box2父盒子未指定高度 -->
        <div class="clearfix"></div>
    </div>
    <div class="footer">footer</div>
</body>
</html>